package com.czjtxy.extraTerm.controller.noticemodule;

import com.czjtxy.extraTerm.entity.VO.TnoticeVO;
import com.czjtxy.extraTerm.server.NoticeService;
import com.czjtxy.extraTerm.serverImpl.NoticeServiceImpl;
import com.czjtxy.extraTerm.util.Util;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @author ZhangYing
 * @class 软件1903
 * @studentID 19852035
 * @date 2021/7/4
 */
@WebServlet(name = "GetOneNoticeServlet", value = "/GetOneNoticeServlet")
public class GetOneNoticeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        TnoticeVO tnoticeVO = null;
        NoticeService noticeService = new NoticeServiceImpl();
        try {
            tnoticeVO = noticeService.getOne(Util.stringToInt(req.getParameter("id")));
            req.setAttribute("tnotice", tnoticeVO);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        req.getRequestDispatcher("notice/showUpdateNotice.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
